<?php
/**
 * 自动跳转页面 - PHP版本
 * 功能：展示倒计时并自动跳转到指定域名目录
 */

 /*兰叶开源
      搬运/使用留名
      发现二改圈钱的④全家出门被车撞④
      By:兰叶
      TG频道:@wzhyz
      TG:@wzfaka

      兰        兰
       兰      兰                                   叶
                                   叶 叶 叶         叶
    兰 兰 兰 兰 兰 兰                叶    叶   叶 叶 叶 叶 叶
                                   叶 叶 叶         叶
      兰 兰 兰 兰                                   叶
                                                   叶
  兰 兰 兰 兰 兰 兰 兰 兰
 */


// 配置参数
$config = [
    'domain_pattern' => '*.7i7p9z.shop',    // 泛解析域名模式
        'domain_pattern' => '*.nmslcnm.icu',    // 泛解析域名模式
            'domain_pattern' => '*.cnmbnmsl.icu',    // 泛解析域名模式
    'target_path' => '/ds',          // 目标目录
    'countdown_seconds' => 5,               // 倒计时秒数
    'page_title' => '页面自动跳转',         // 页面标题
    'heading_text' => '正在为您跳转',       // 主标题
    'message_text' => '系统将在 %s 秒后自动跳转到 %s', // 提示信息
    'manual_link_text' => '立即访问',       // 手动跳转按钮文本
    'manual_link_desc' => '如果您的浏览器没有自动跳转，请点击下方按钮', // 手动跳转描述
    'primary_color' => '#8B5CF6',           // 主色调（紫色）
    'secondary_color' => '#EC4899',         // 辅助色调（粉色）
    'accent_color' => '#3B82F6',            // 强调色（蓝色）
    'sakura_enabled' => true,               // 是否启用樱花效果
    'sakura_count' => 30,                   // 樱花数量
];

// 获取当前访问的域名
$currentDomain = $_SERVER['HTTP_HOST'];

// 从域名中提取子域名部分（处理泛解析）
$domainPattern = str_replace('*.', '', $config['domain_pattern']);
$subdomain = str_replace('.'.$domainPattern, '', $currentDomain);

// 构建跳转URL - 使用当前域名 + 指定目录
$targetUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$currentDomain{$config['target_path']}";

// 倒计时秒数也可以通过URL参数设置
if (isset($_GET['seconds']) && is_numeric($_GET['seconds'])) {
    $seconds = max(1, min(30, (int)$_GET['seconds'])); // 限制在1-30秒之间
} else {
    $seconds = $config['countdown_seconds'];
}

// 页面样式配置
$styleConfig = [
    'background' => 'bg-gradient-to-br from-purple-50 to-pink-50',
    'card' => 'bg-white/90 rounded-3xl shadow-2xl p-8 transform transition-all duration-500 hover:shadow-xl hover:-translate-y-1 backdrop-blur-sm',
    'title' => 'text-[clamp(1.75rem,4vw,2.5rem)] font-bold text-gray-800 mb-3 tracking-tight',
    'message' => 'text-gray-600 text-lg leading-relaxed',
    'button' => 'inline-flex items-center px-8 py-3.5 bg-gradient-to-r from-primary to-secondary text-white rounded-xl shadow-lg hover:shadow-xl transition-all duration-300 focus:outline-none focus:ring-4 focus:ring-primary/30 text-lg font-medium',
];

// 如果是移动设备，调整一些样式
if (preg_match('/(android|iphone|ipad|tablet)/i', $_SERVER['HTTP_USER_AGENT'])) {
    $styleConfig['card'] = 'bg-white/90 rounded-3xl shadow-xl p-6 transition-all duration-300 backdrop-blur-sm';
    $styleConfig['title'] = 'text-[clamp(1.5rem,5vw,2rem)] font-bold text-gray-800 mb-3';
    $styleConfig['button'] = 'inline-flex items-center px-6 py-3 bg-gradient-to-r from-primary to-secondary text-white rounded-xl shadow-lg hover:shadow-xl transition-all duration-300 focus:outline-none focus:ring-4 focus:ring-primary/30 text-base font-medium';
}
?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= htmlspecialchars($config['page_title']) ?></title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '<?= $config['primary_color'] ?>',
                        secondary: '<?= $config['secondary_color'] ?>',
                        accent: '<?= $config['accent_color'] ?>',
                        neutral: {
                            100: '#F3F4F6',
                            200: '#E5E7EB',
                            300: '#D1D5DB',
                            800: '#1F2937',
                            900: '#111827',
                        }
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                    animation: {
                        'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
                        'float': 'float 6s ease-in-out infinite',
                        'fall': 'fall 10s linear forwards',
                    },
                    keyframes: {
                        float: {
                            '0%, 100%': { transform: 'translateY(0)' },
                            '50%': { transform: 'translateY(-10px)' },
                        },
                        fall: {
                            '0%': { transform: 'translateY(-10px) rotate(0deg)' },
                            '100%': { transform: 'translateY(100vh) rotate(360deg)' },
                        }
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .text-shadow {
                text-shadow: 0 2px 4px rgba(0,0,0,0.1);
            }
            .glass-effect {
                backdrop-filter: blur(10px);
                background-color: rgba(255, 255, 255, 0.7);
            }
            .gradient-border {
                position: relative;
                border-radius: 0.75rem;
                z-index: 0;
            }
            .gradient-border::before {
                content: "";
                position: absolute;
                inset: -2px;
                border-radius: 0.85rem;
                background: linear-gradient(135deg, <?= $config['primary_color'] ?>, <?= $config['secondary_color'] ?>);
                z-index: -1;
            }
            .sakura {
                position: absolute;
                top: -10px;
                pointer-events: none;
                background-color: rgba(255, 255, 255, 0);
            }
            .sakura-petal {
                position: absolute;
                width: 10px;
                height: 10px;
                background: linear-gradient(135deg, rgba(236, 72, 153, 0.8), rgba(139, 92, 246, 0.8));
                border-radius: 150% 0 150% 0;
                animation: fall linear forwards;
            }
        }
    </style>
</head>
<body class="<?= $styleConfig['background'] ?> min-h-screen font-inter flex items-center justify-center p-4 overflow-x-hidden">
    <!-- 装饰元素 -->
    <div class="absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none">
        <div class="absolute -top-20 -left-20 w-64 h-64 bg-primary/10 rounded-full blur-3xl"></div>
        <div class="absolute top-1/4 -right-20 w-80 h-80 bg-secondary/10 rounded-full blur-3xl"></div>
        <div class="absolute bottom-0 left-1/3 w-96 h-96 bg-accent/5 rounded-full blur-3xl"></div>

        <!-- 樱花效果容器 -->
        <div id="sakura-container" class="absolute top-0 left-0 w-full h-full overflow-hidden"></div>
    </div>

    <div class="max-w-md w-full <?= $styleConfig['card'] ?> relative z-10">
        <!-- 顶部图标 -->
        <div class="text-center mb-8">
            <div class="inline-flex items-center justify-center w-20 h-20 rounded-full bg-gradient-to-br from-primary/20 to-secondary/20 mb-5 animate-float">
                <i class="fa fa-arrow-right text-gradient bg-clip-text text-transparent bg-gradient-to-r from-primary to-secondary text-3xl"></i>
            </div>
            <h1 class="<?= $styleConfig['title'] ?> text-shadow bg-clip-text text-transparent bg-gradient-to-r from-primary to-secondary">
                <?= htmlspecialchars($config['heading_text']) ?>
            </h1>
            <p class="<?= $styleConfig['message'] ?>">
                <?= sprintf(htmlspecialchars($config['message_text']),
                           '<span id="countdown" class="bg-clip-text text-transparent bg-gradient-to-r from-primary to-secondary font-bold text-2xl">'. $seconds .'</span>',
                           htmlspecialchars($currentDomain . $config['target_path'])) ?>
            </p>
        </div>

        <!-- 进度条 -->
        <div class="mb-8">
            <div class="h-3 w-full bg-gray-100 rounded-full overflow-hidden shadow-inner">
                <div id="progress-bar" class="h-full bg-gradient-to-r from-primary via-secondary to-accent rounded-full transition-all duration-300" style="width: 100%"></div>
            </div>
        </div>

        <!-- 域名信息 -->
        <div class="mb-8 p-4 rounded-xl bg-purple-50 border border-purple-100">
            <div class="flex items-center text-sm text-gray-600">
                <i class="fa fa-info-circle text-primary mr-2"></i>
                <span>您正在访问：<strong class="text-gray-800"><?= htmlspecialchars($currentDomain) ?></strong></span>
            </div>
            <div class="mt-2 flex items-center text-sm text-gray-600">
                <i class="fa fa-link text-primary mr-2"></i>
                <span>即将跳转至：<strong class="text-gray-800 break-all"><?= htmlspecialchars($targetUrl) ?></strong></span>
            </div>
        </div>

        <!-- 手动跳转按钮 -->
        <div class="text-center">
            <p class="text-gray-500 text-sm mb-5">
                <i class="fa fa-clock-o mr-1"></i> <?= htmlspecialchars($config['manual_link_desc']) ?>
            </p>
            <a href="<?= htmlspecialchars($targetUrl) ?>" id="redirect-link" class="<?= $styleConfig['button'] ?> gradient-border">
                <i class="fa fa-external-link mr-2"></i><?= htmlspecialchars($config['manual_link_text']) ?>
            </a>
        </div>
    </div>

    <script>
        // 设置跳转目标URL
        const redirectUrl = '<?= htmlspecialchars($targetUrl) ?>';
        document.getElementById('redirect-link').href = redirectUrl;

        // 倒计时功能
        let seconds = <?= $seconds ?>;
        const countdownElement = document.getElementById('countdown');
        const progressBar = document.getElementById('progress-bar');

        function updateCountdown() {
            seconds--;
            countdownElement.textContent = seconds;
            progressBar.style.width = `${(seconds / <?= $seconds ?>) * 100}%`;

            // 添加进度条颜色变化效果
            const hue = (seconds / <?= $seconds ?>) * 180; // 从紫色(270)到蓝色(210)
            progressBar.style.background = `linear-gradient(90deg, hsl(270, 100%, 60%), hsl(${hue}, 100%, 50%))`;

            if (seconds <= 0) {
                window.location.href = redirectUrl;
            }
        }

        // 启动倒计时
        setInterval(updateCountdown, 1000);

        // 添加页面载入动画
        document.addEventListener('DOMContentLoaded', () => {
            const card = document.querySelector('<?= str_replace('"', '\\"', ".max-w-md") ?>');
            card.classList.add('opacity-0', 'translate-y-8');
            setTimeout(() => {
                card.classList.remove('opacity-0', 'translate-y-8');
            }, 100);

            // 创建樱花效果
            if (<?= $config['sakura_enabled'] ? 'true' : 'false' ?>) {
                createSakura();
            }
        });

        // 创建樱花飘落效果
        function createSakura() {
            const container = document.getElementById('sakura-container');
            const count = <?= $config['sakura_count'] ?>;

            for (let i = 0; i < count; i++) {
                setTimeout(() => {
                    const sakura = document.createElement('div');
                    sakura.className = 'sakura';

                    // 随机位置
                    const left = Math.random() * 100;
                    const delay = Math.random() * 10;
                    const duration = Math.random() * 10 + 10;
                    const size = Math.random() * 10 + 5;
                    const opacity = Math.random() * 0.5 + 0.3;

                    sakura.style.left = `${left}%`;
                    sakura.style.animation = `fall ${duration}s linear ${delay}s infinite`;

                    // 创建花瓣
                    const petal = document.createElement('div');
                    petal.className = 'sakura-petal';
                    petal.style.width = `${size}px`;
                    petal.style.height = `${size}px`;
                    petal.style.opacity = opacity;

                    // 随机旋转角度
                    const rotation = Math.random() * 360;
                    petal.style.transform = `rotate(${rotation}deg)`;

                    // 随机颜色
                    const hue = Math.random() * 30 + 280; // 粉色到紫色的色调
                    const saturation = Math.random() * 20 + 80; // 80-100%
                    const lightness = Math.random() * 10 + 60; // 60-70%
                    petal.style.background = `linear-gradient(135deg, hsla(${hue}, ${saturation}%, ${lightness}%, 0.8), hsla(${(hue+30)}, ${saturation}%, ${lightness-10}%, 0.8))`;

                    sakura.appendChild(petal);
                    container.appendChild(sakura);

                    // 自动移除超出屏幕的花瓣
                    setTimeout(() => {
                        sakura.remove();
                    }, (duration + delay) * 1000);
                }, i * 300);
            }
        }
    </script>
</body>
</html>


/*兰叶开源
     搬运/使用留名
     发现二改圈钱的④全家出门被车撞④
     By:兰叶
     TG频道:@wzhyz
     TG:@wzfaka

     兰        兰
      兰      兰                                   叶
                                  叶 叶 叶         叶
   兰 兰 兰 兰 兰 兰                叶    叶   叶 叶 叶 叶 叶
                                  叶 叶 叶         叶
     兰 兰 兰 兰                                   叶
                                                  叶
 兰 兰 兰 兰 兰 兰 兰 兰
*/
